<template>
	<view class="w-100">
		<template>
			<view class="container">
				<web-view :src="webUrl"></web-view>
			</view>
		</template>
	</view>
</template>

<script>
	import {
		md5
	} from '@/utils/md5.js'
	import {
		userInfoUrl,
	} from "@/api/index.js"
	export default {
		data() {
			return {
				webUrl: '',
				userInfo: ''
			}
		},
		mounted() {
			this.token = uni.getStorageSync('token')
			if (this.token != '') {
				this.getUserInfo().then(() => {
					this.generateH5Url()
				})
			}
		},
		methods: {
			getUserInfo() {
				return new Promise((resolve, reject) => {
					this.$R.get(userInfoUrl).then(res => {
						this.userInfo = res.data
						resolve()
					}).catch(error => {
						reject(error)
					})
				})
			},
			generateH5Url() {
				const userId = this.userInfo.id
				console.log('111111', userId)
				const channelId = '848'
				const secretKey = '70d0fdb5d35c4fb0a5089338d9e0879d'
				const params = `channelId=${channelId}&userId=${userId}`
				let sign = channelId + '-' + secretKey + ':sdkUserId=' + userId + '&'
				console.log('9999', sign);
				sign = md5(sign).toUpperCase()
				const h5Url = `https://sdkh5.gouzixsw.com/#/?${params}&sign=${sign}`
				this.webUrl = h5Url
			}
		}
	}
</script>

<style lang="scss">
</style>